{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .childrenBody {
        background: #fff;
    }
</style>
<!--<style type="text/css">-->
<!--    .layui-layer-page .layui-layer-content {-->
<!--        overflow: inherit;-->
<!--    }-->
<!--</style>-->
<div class="layui-card">
    <div class="layui-card-header">兑换商品</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable"></table>
    </div>
</div>
<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.first_img}}" data-image="{{d.name}}">

</script>
<script type="text/html" id="barTool">
<!--    <a class="layui-btn layui-btn-xs btn-warm" data-open='{:url("cvedit")}?id={{ d.id }}' data-title="视频设置">视频设置</a>-->
<!--    <a class="layui-btn layui-btn-xs layui-btn-warm" data-open='{:url("hdedit")}?id={{ d.id }}' data-title="活动设置">活动设置</a>-->
<!--    <a class="layui-btn layui-btn-xs layui-btn-normal   layui-btn-norma" data-open='{:url("fxleveledit")}?id={{ d.id }}' data-title="直推返现"-->
<!--       >直推返现</a>-->
    {if $userInfo['roleid']==1}
    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={{ d.id }}' data-title="编辑内容"
       data-full="true">编辑</a>
    <a href='{:url("del",["catid"=>$catid])}?ids={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del">删除</a>
    {/if}
</script>


<script type="text/html" id="recommendTpl">
    <input type="checkbox" name="recommend" data-href='{:url("recommend")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="推荐|不推荐" lay-filter="switchStatus" {{ d.recommend==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTpl">
    <input type="checkbox" name="status" data-href='{:url("setstate")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="上架|下架" lay-filter="switchStatus" {{ d.status==1 ? 'checked' : '' }}>
</script>

<script type="text/html" id="statusTplc">
    <input type="checkbox" name="is_show_c" data-href='{:url("setstatec")}?id={{d.id}}' value="{{d.id}}"
           lay-skin="switch"
           lay-text="显示|关闭" lay-filter="switchStatus" {{ d.is_show_c==1 ? 'checked' : '' }}>
</script>



{/block}
{block name="script"}
<script>
    layui.use(['table', 'yznTable'], function () {
        // var table = layui.table,
        //     $ = layui.$,
        //     form = layui.form,
        //     table = layui.table,
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            add_url: "{:url('add',['catid'=>$catid])}",
            delete_url: "{:url('del',['catid'=>$catid])}",
            modify_url: '{:url("listorder",["catid"=>$catid])}',
        };
        var goods_cate = {:json_encode($goodsCategoty)};
        table.render({
            init: init,
            id: 'currentTable',
            elem: '#currentTable',
            url: '{:url("index")}',
            // searchFormTpl:,
            toolbar: ['refresh',
                [{
                    text: '添加',
                    url: init.add_url,
                    method: 'open',
                    icon: 'iconfont icon-add',
                    class: 'layui-btn layui-btn-normal layui-btn-sm',
                    extend: 'data-full="true"',
                }],
            ],
              cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id',align: "center",  width: '4%', title: 'ID'},
                    {
                        field: 'goods_cate.name',
                        align: "center",
                        title: '商品分类',
                        width: '10%',
                        unresize: true,
                        // search: false,
                        selectList: goods_cate
                    },
                    {field: 'name',align: "center",  width: '15%', title: '商品名称'},
                    {field: 'first_img', align: "center", width: '10%', title: '商品图片', templet: '#picTpl',search: false},
                    {field: 'points',  width: '10%', align: "center", title: '需要购物卷',search: false},
                    {field: 'sale_num',  width: '10%', align: "center", title: '兑换数量',search: false},
                    // {field: 'stock',  width: '8%', align: "center", title: '库存',search: false},
                    // {field: 'spec_num',  width: '8%', align: "center", title: '规格数量',search: false},
                    {field: 'sort', width: '8%', align: "center", title: '排序',search: false},
                    // {
                    //     field: 'recommend',
                    //     width: '10%',
                    //     align: "center",
                    //     title: '推荐',
                    //     templet: '#recommendTpl',
                    //     unresize: true,
                    //     selectList: {0: '正常', 1: '推荐'}
                    // },
                    {
                        field: 'status',
                        width: '8%',
                        align: "center",
                        title: '状态',
                        templet: '#statusTpl',
                        unresize: true,
                        selectList: {0: '下架', 1: '上架'}
                    },
                    // {
                    //     field: 'is_show_c',
                    //     width: '10%',
                    //     align: "center",
                    //     title: '视频',
                    //     templet: '#statusTplc',
                    //     unresize: true,
                    //     selectList: {0: '关闭', 1: '显示'}
                    // },
                    {field: 'create_time',  width: '15%', align: "center", title: '创建时间', search: 'range'},
                    {fixed: 'right',  width: '20%',align: "center", title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });
        selectElement2 = document.getElementById('searchFieldset_currentTable');
        selectElement2.classList.remove("layui-hide");
        var element = document.getElementById('layui-input-search');
        element.parentNode.removeChild(element);
        yznTable.bindevent();
    });
</script>
{/block}